﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class user_user_reg : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
        }
        else
        {
            btnSubmit.Attributes.Add("OnClick", "javascript:return chk();");
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        TUser oUser = new TUser();
        if(oUser.FindKey("email",email.Text))
        {
            msg.Text="该邮件地址已经被使用,请使用其它地址注册!";
        }
        else
        {
            oUser.EMail = email.Text;
            oUser.PassWord = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text, "MD5");
            oUser.BigName = name.Text;
            //---
            oUser.UserName = "";
            oUser.MyName = "";
            oUser.MySex = "";
            oUser.MyCompany = "";
            oUser.MyDept = "";
            oUser.MyPic = "";
            oUser.MyIntro = "";
            oUser.Status = 0;//未验证
            oUser.Insert();
            //发送验证邮件
            if (TCommon.mySendMail(email.Text))
            {
                //转向
                this.Response.Redirect("user_reg_ok.aspx?email=" + Server.UrlEncode(email.Text));
            }
            else
            {
                msg.Text = "邮件发送失败,请检查邮箱是否有效!";
            }
        }
    }
}
